package com.timk.goserver.client.services;

import java.util.List;

import com.google.gwt.user.client.rpc.RemoteService;
import com.timk.goserver.client.model.GameInvite;
import com.timk.goserver.client.model.Message;

/**
 * Service for sending invites and messages
 * @author TKington
 *
 */
public interface MessageService extends RemoteService {
	/** Success */
	int STATUS_SUCCESS = 0;
	/** Wrong user to accept invite */
	int STATUS_WRONG_USER = 1;
	/** Invite doesn't exist */
	int STATUS_NO_SUCH_INVITE = 2;
	/** Handicap not supported */
	int STATUS_UNSUPPORTED_HANDICAP = 3;
	/** Size not supported */
	int STATUS_UNSUPPORTED_SIZE = 4;
	/** User doesn't exist */
	int STATUS_NO_SUCH_USER = 5;
	/** Message doesn't exist */
	int STATUS_NO_SUCH_MESSAGE = 6;
	/** Can't be rated with these settings */
	int STATUS_CANT_BE_RATED = 7;
	
	/**
	 * Sends an invite
	 * @param invite the GameInvite
	 * @return integer error code
	 * @throws NoSessionException if the session has expired
	 */
	int sendInvite(GameInvite invite) throws NoSessionException;
	
	/**
	 * Gets the list of open invites for this user
	 * @return List&lt;GameInvite&gt;
	 * @throws NoSessionException if the session has expired
	 * 
	 * @gwt.typeArgs <com.timk.goserver.client.model.GameInvite>
	 */
	List getInvites() throws NoSessionException;
	
	/**
	 * Accepts a game invite
	 * @param inviteId
	 * @return integer error code
	 * @throws NoSessionException if the session has expired
	 */
	int acceptInvite(int inviteId) throws NoSessionException;
	
	/**
	 * Refuses a game invite
	 * @param inviteId
	 * @return integer error code
	 * @throws NoSessionException if the session has expired
	 */
	int refuseInvite(int inviteId) throws NoSessionException;
	
	/**
	 * Sends a message
	 * @param msg
	 * @return integer error code
	 * @throws NoSessionException if the session has expired
	 */
	int sendMessage(Message msg) throws NoSessionException;
	
	/**
	 * Retrieves messages for the current user
	 * @return List&lt;Message&gt;
	 * @throws NoSessionException if the session has expired
	 * 
	 * @gwt.typeArgs <com.timk.goserver.client.model.Message>
	 */
	List getMessages() throws NoSessionException;
	
	/**
	 * Deletes a message
	 * @param messageId the message id
	 * @return integer error code
	 * @throws NoSessionException if the session has expired
	 */
	int deleteMessage(int messageId) throws NoSessionException;
}
